<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="chtml" uri="http://www.szhelper.com/jsp/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>评论列表</title>

<script type="text/javascript" defer="defer">
/**
 * 删除、屏蔽、审核评论通用函数
 **/
var doOperatByType = function(__req_url, __ids, __checkboxName, formid, typeDesc, type) {
	var __param_ids = "";/* 组合后要操作的记录ID */
	if (document.getElementsByName(__checkboxName) == null
		|| document.getElementsByName(__checkboxName).length <= 0) {
		alert("没有要"+typeDesc+"的记录!");
		return null;
	}
	/* 选中的复选框值 */
	var __select = helper.fun.getCheckbox(__checkboxName);
	if (__select == null || __select.length <= 0) {
		alert("请选择您要"+typeDesc+"的记录!");
		return null;
	}
	
	//只允许删除已屏蔽的评论
	if(type == 'DEL') {
		var flag = true;
		for(var i=0, len=__select.length; i<len; i++) {
			var allTr = $("#main_table4discussList tr");
			for(var j=0, lenj=allTr.length; j<lenj; j++) {
				var partn = new RegExp("value=\"" + __select[i] + "\"");
				var findpartn = /已屏蔽/;
				var text = $(allTr[j]).html();
				if(partn.test(text) && !findpartn.test(text)) {
					flag = false;
					break;
				}
			}
			if(!flag) break;
		}
		if(!flag) {
			alert("温馨提示：\n只允许删除已屏蔽的评论！");
			return;
		}
	}
	
	/* 组合请求参数 */
	__param_ids = helper.fun.joinArgs(__select, __ids);
	/* 屏蔽(YES)或不屏蔽(NO) 审核(YES)或未审核(NO) */
	if(type != null && type != '' && type != 'DEL') {
		__param_ids = __param_ids + "&type=" + type;
	}
	if (confirm("确定"+typeDesc+"选中记录?")) {
		var form = document.getElementById(formid);
		var ac = form.action;
		form.action = __req_url + __param_ids;
		form.submit();
		form.action = ac;
	}
};

$(document).ready(function(){
	/**
	 * 标记颜色
	 **/
	var changeColor = function(){
		$("td[title='待审核']").each(function(){
			$(this).attr("style", "color: #F00;");
		});
		$("td[title='已屏蔽']").each(function(){
			$(this).attr("style", "color: #0E0;");
		});
	};
	changeColor();
});
</script>
<style type="text/css">
.butcss {
	border: 2px solid #DDEEE0;
	background-color: #FFF;
}
.msgcss {
	color: #F00;
}
.padcss {
	padding: 5px;
}
</style>
</head>
<body>
<div class="youarehere">网站内容管理 &gt; <span>审核评论</span></div>
<form action='<chtml:path path="/" />am/discuss' method="post" id="discussForm">
<table width="99%" align="center" border="0" cellpadding="1" cellspacing="1" class="data_table">
	<tr>
		<td class="data_tab_th" colspan="4">查询评论</td>
	</tr>
	<tr>
		<td class="data_tab_tdr">新闻ID</td>
		<td class="data_tab_tdl"><input type="text" value="${articleId }" name="articleId" /></td>
		<td class="data_tab_tdr">审核人</td>
		<td class="data_tab_tdl"><input type="text" value="${auditor }" name="auditor" /></td>
	</tr>
	<tr>
		<td class="data_tab_tdr">评论内容</td>
		<td class="data_tab_tdl"><input type="text" value="${content }" name="content" /></td>
		<td class="data_tab_tdr">评论人</td>
		<td class="data_tab_tdl"><input type="text" value="${userName }" name="userName" /></td>
	</tr>
	<tr>
		<td class="data_tab_tdr">评论时间</td>
		<td class="data_tab_tdl"><input type="text"
			value="${publishTime_s}" name="publishTime_s" id="publishTime_s"/>
		<script type="text/javascript">
			Calendar.showDate("publishTime_s");
		</script>&nbsp;到&nbsp;<input
			type="text" value="${publishTime_e}" name="publishTime_e"
			id="publishTime_e"/>
		<script type="text/javascript">
			Calendar.showDate("publishTime_e");
		</script>
		</td>
		<td class="data_tab_tdr">审核时间</td>
		<td class="data_tab_tdl"><input type="text"
			value="${auditTime_s}" name="auditTime_s" id="auditTime_s" />
		<script type="text/javascript">
			Calendar.showDate("auditTime_s");
		</script>&nbsp;到&nbsp;<input
			type="text" value="${auditTime_e}" name="auditTime_e"
			id="auditTime_e" />
		<script type="text/javascript">
			Calendar.showDate("auditTime_e");
		</script>
		</td>
	</tr>
	<tr>
		<td class="data_tab_tdr">评论状态</td>
		<td class="data_tab_tdl">
			<select name="state">
				<c:choose>
					<c:when test="${state eq 'AUDIT'}"><c:set var="Audit_Y">selected</c:set></c:when>
					<c:when test="${state eq 'NOAUDIT'}"><c:set var="Audit_N">selected</c:set></c:when>
					<c:when test="${state eq 'MASK'}"><c:set var="Mask_Y">selected</c:set></c:when>
				</c:choose>
				<option value="-1">全部</option>
				<option value="AUDIT" ${Audit_Y }>已审核</option>
				<option value="NOAUDIT" ${Audit_N }>未审核</option>
				<option value="MASK" ${Mask_Y }>已屏蔽</option>
			</select>
		</td>
		<td class="data_tab_tdr"></td>
		<td class="data_tab_tdl"></td>
	</tr>
	<tr>
		<td align="center" colspan="4"class="bg_bai">
		
		<div class="mr_20 t_c">
			<input type="submit" class="pub_bt" value="查询" onclick='document.getElementsByName("PaginationButton_CurrentPage4list")[0].value=1;'/>
			<input type="button" class="pub_bt" value="清空" onclick="this.form.reset();" />
			<input type="button" class="pub_bt" value="返回新闻列表" onclick="javascript:window.location.href='<%=request.getContextPath()%>/am/list'" />
		</div>
			
	    </td>
	</tr>
</table>
<br />
										   
<chtml:list collection="discussList" type="com.hengpeng.itfinoss.controller.vo.ArticleDiscussVo" 
	includeFields="userName,discussContent,publishTime,state,auditor,auditTime,articleCategory,articleAuthor,articleId"
	showCheckBox="true" title="评论列表" paginationName="discussListPage" detailLink="preview/@{articleId}" showLinkField="discussContent"
	allowSort="false">
	<input type="button" title="只能删除已屏蔽评论" value="删除所选"
		onclick="javascript:doOperatByType('<%=request.getContextPath()%>/am/discuss/remove','ids','id4discussList','discussForm','删除','DEL');" />
	<input type="button" value="屏蔽所选"
		onclick="javascript:doOperatByType('<%=request.getContextPath()%>/am/discuss/updateState','ids','id4discussList','discussForm','屏蔽','MASK');" />
	<input type="button" value="提交审核通过"
		onclick="javascript:doOperatByType('<%=request.getContextPath()%>/am/discuss/updateState','ids','id4discussList','discussForm','审核通过','AUDIT');" />
</chtml:list>

</form>
<!--说明   -->	
<div class="sm_info">
	<p class="row_one">说明：</p>
	<p class="other"></p>
	<p class="other"></p>
</div>
</body>
</html>